﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>My First Widget</title>
		<script language="javascript" type="text/javascript">
		    function onload() {
		        var mnuWrite = widget.menu.createMenuItem(0);
		        mnuWrite.text = "write";
		        mnuWrite.onSelect = function() { widget.setPreferenceForKey("Hello", "Data"); }
		        widget.menu.append(mnuWrite);
		        
		        var mnuRead = widget.menu.createMenuItem(1);
		        mnuRead.text = "Read";
		        mnuRead.onSelect = function() { alert(widget.preferenceForKey("Data")); }
		        widget.menu.append(mnuRead);

		        var SystemState = widget.createObject("SystemState");
		        SystemState.DisplayRotation.addEventListener("changed", function() { alert("Rotate!"); });

		        var BatteryStrength = SystemState.PowerBatteryStrength;
		        BatteryStrength.addEventListener("changed", function() { alert(BatteryStrength.value); });
		        
		        alert(widget.width + 'X' + widget.height);
		    }
		</script>
	</head>
	<body onload="onload();">
	    A Simple Widget
	</body>
</html>